package com.dodayum.schedule;

import com.dodayum.dao.WeiBoNews;
import com.dodayum.service.GetWeiBoNewsService;
import com.dodayum.service.RealtimeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Date;

@Component
@EnableScheduling
@Slf4j
public class GetNewsSchedule {

    private static final int SCHEDULE_TIME = 1000 * 60;

    @Resource
    private GetWeiBoNewsService getWeiBoNewsService;
    @Resource
    private RealtimeService realtimeService;

    //    @Scheduled(fixedRate = SCHEDULE_TIME)
    private void getWeiBoNewsSchedule() {
        WeiBoNews weiBoNews = getWeiBoNewsService.getWeiBoNews();
        realtimeService.insertNewRealtimeList(weiBoNews.getData().getRealtime());
        log.info("执行完成，执行时间\t{}", new Date());
    }
}
